package cn.otrue.patienthealthmanager.adapter;

import android.app.Activity;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout.LayoutParams;
import cn.otrue.patienthealthmanager.R;

public class ScrollTabsAdapter extends TabAdapter {
	private Activity activity;
	private int num;
	DisplayMetrics dm;

	public ScrollTabsAdapter(Activity activity, int num) {
		super();
		// TODO Auto-generated constructor stub
		this.activity = activity;
		this.num = num;
		dm = new DisplayMetrics();
		activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
	}

	@Override
	public View getView(int position) {
		// TODO Auto-generated method stub
		LayoutInflater inflater = (LayoutInflater) activity
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		LayoutParams params = new LayoutParams(dm.widthPixels / num,
				LayoutParams.MATCH_PARENT);
		Button button = (Button) inflater.inflate(R.layout.item_viewpager_tabs,
				null);
		button.setText(tabsList.get(position));
		button.setLayoutParams(params);
		return button;
	}
}
